﻿'<Get Linux is a open source lightweight download client for operating systems.>
'    Copyright (C) <2014>  <Dev-fire>

'    This program is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 3 of the License, or
'    (at your option) any later version.

'    This program is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.

'    You should have received a copy of the GNU General Public License
'    along with this program.  If not, see <http://www.gnu.org/licenses/>.
Public Class Data
    Shared AutoComplete_Operating_Systems As New AutoCompleteStringCollection()
    'OSL List
    Shared Sub OSL_List()
        Try
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Action: Loading Operating System List" & vbCrLf) 'DEBUG ACTION LOG -
            'Check For Data Folder
            If Not Directory.Exists(Application.StartupPath & "\Data\") Then
                Directory.CreateDirectory(Application.StartupPath & "\Data\")
            End If
            'Check For Icons Folder
            If Not Directory.Exists(Application.StartupPath & "\Data\Icons\") Then
                Directory.CreateDirectory(Application.StartupPath & "\Data\Icons\")
            End If
            Main.ListView1.Items.Clear()
            Dim OSL_CFG_Stream As Stream = Main.CFG_WebClient.OpenRead("https://get-linux.googlecode.com/svn/trunk/Data/Operating Systems/OSL.cfg")
            Dim OSL_Reader As New StreamReader(OSL_CFG_Stream)
            Do While OSL_Reader.EndOfStream = False
                Dim line As String = OSL_Reader.ReadLine()
                If Not File.Exists(Application.StartupPath & "\Data\Icons\" & line & ".png") Then
                    Splash.Loading = "Downloading:" & line & ".png"
                    Splash.Loading_AccessControl()
                    Main.CFG_WebClient.DownloadFile(New Uri("https://get-linux.googlecode.com/svn/trunk/Data/Operating Systems/" & line & "/Icon.png"), Application.StartupPath & "\Data\Icons\" & line & ".png")
                End If
                Splash.Loading = "Loading: " & line
                Splash.Loading_AccessControl()
                Main.ImageList_Main.Images.Add(line, Image.FromFile(Application.StartupPath & "\Data\Icons\" & line & ".png"))
                Main.ListView1.Items.Add(line, line)
                AutoComplete_Operating_Systems.Add(line)
            Loop
            OSL_Reader.Close() 'Close StreamReader
            OSL_CFG_Stream.Close() 'Close Stream
            Main.TextBox_Search_For_OS.AutoCompleteCustomSource = AutoComplete_Operating_Systems
            Main.Label_Title.Text = Main.Text & " - " & Main.ListView1.Items.Count.ToString & " Operating Systems"
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Information: Operating System List Loaded" & vbCrLf) 'DEBUG ACTION LOG -
        Catch Wx As System.Net.WebException
            Main.NotifyIcon_Main.BalloonTipText = "Connection Failed: " & Wx.Message
            Main.NotifyIcon_Main.ShowBalloonTip(1500)
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Error: Connection Failed (" & Wx.Message & ")" & vbCrLf) 'DEBUG ACTION LOG -
            'Update Variables on debug window
            Debug.Variables()
        Catch Ex As Exception
            MsgBox(Ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    'Play Startup Sound
    Shared Sub Play_Startup_Sound()
        Try
            If Settings.CheckBox_Startup_Sound_Enabled.Checked Then 'User wants to hear sound
                If Settings.RadioButton_Startup_Sound_User.Checked Then 'User wants to hear there own selected sound
                    If File.Exists(Settings.TextBox_Startup_Sound_Path.Text) Then 'If the users selected sound exists
                        My.Computer.Audio.Play(Settings.TextBox_Startup_Sound_Path.Text) 'Play users selected sound
                    Else
                        Settings.RadioButton_Startup_Sound_Default.Checked = True 'Select default for the user
                    End If
                ElseIf Settings.RadioButton_Startup_Sound_Default.Checked Then 'User wants to hear the default sound
                    My.Computer.Audio.Play(My.Resources.Startup, AudioPlayMode.Background) 'Play default sound
                End If
            End If
        Catch Ex As Exception
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Error: Default startup sound settings will be loaded." & vbCrLf) 'DEBUG ACTION LOG -
            Settings.RadioButton_Startup_Sound_Default.Checked = True 'Select default for the user
        End Try
    End Sub
    'Play Completed sound
    Shared Sub Play_Completed_Sound()
        Try
            If Settings.CheckBox_Download_Complete_Sound_Enabled.Checked Then ' User wants to hear sound
                If Settings.RadioButton_Download_Complete_Sound_User.Checked Then 'User wants to hear there own selected sound
                    If File.Exists(Settings.TextBox_Download_Complete_Sound_Path.Text) Then 'If the users selected sound exists
                        My.Computer.Audio.Play(Settings.TextBox_Download_Complete_Sound_Path.Text) 'Play users selected sound
                    Else
                        Settings.RadioButton_Download_Complete_Sound_Default.Checked = True 'Select default for the user
                    End If
                ElseIf Settings.RadioButton_Download_Complete_Sound_Default.Checked Then 'User want to hear the default sound
                    My.Computer.Audio.Play(My.Resources.Complete, AudioPlayMode.Background) 'Play default sound
                End If
            End If
        Catch Ex As Exception
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Error: Default download complete sound settings will be loaded." & vbCrLf) 'DEBUG ACTION LOG -
            Settings.RadioButton_Download_Complete_Sound_Default.Checked = True 'Select default for the user
        End Try
    End Sub
    'Auto Select Random Category And OS
    Shared Sub Auto_Select_OS()
        Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Action: Selecting Random OS" & vbCrLf) 'DEBUG ACTION LOG -
        Dim RandomClass As New Random()
        Dim RandomOS As Integer = RandomClass.Next(Main.ListView1.Items.Count)
        If Not Main.ListView1.Items.Count = 0 Then
            Main.ListView1.Items(RandomOS).Selected = True
            Main.ListView1.Items(RandomOS).EnsureVisible()
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Information: Random OS Selected (" & Main.ListView1.Items(RandomOS).Text & ")" & vbCrLf) 'DEBUG ACTION LOG -
        End If
    End Sub
    'Save Settings
    Shared Sub Save_Settings()
        Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("HH:mm:ss.fff tt") & "> " & "Action: Saving Settings" & vbCrLf) 'DEBUG ACTION LOG -
        If Not Directory.Exists(Application.StartupPath & "\Data\") Then
            Directory.CreateDirectory(Application.StartupPath & "\Data\")
        End If
        Dim Write_Settings_CFG As New StreamWriter(Application.StartupPath & "\Data\Settings.cfg")
        'Download Completed Option
        If Settings.RadioButton_Do_Nothing.Checked Then
            Write_Settings_CFG.WriteLine("DownloadCompletedOption:" & 1)
        ElseIf Settings.RadioButton_Open_Download_File.Checked Then
            Write_Settings_CFG.WriteLine("DownloadCompletedOption:" & 2)
        ElseIf Settings.RadioButton_Open_Download_Folder.Checked Then
            Write_Settings_CFG.WriteLine("DownloadCompletedOption:" & 3)
        ElseIf Settings.RadioButton_Burn_ISO.Checked Then
            Write_Settings_CFG.WriteLine("DownloadCompletedOption:" & 4)
        End If
        'Download Enabled
        Write_Settings_CFG.WriteLine("DownloadEnabled:" & Settings.CheckBox_Download_Enabled.Checked.ToString)
        'Download Path
        If Settings.RadioButton_Download_User.Checked Then
            If Directory.Exists(Settings.TextBox_Download_Path.Text) Then
                Write_Settings_CFG.WriteLine("DownloadPath:" & Settings.TextBox_Download_Path.Text)
            Else
                Write_Settings_CFG.WriteLine("DownloadPath:")
            End If
        Else
            Write_Settings_CFG.WriteLine("DownloadPath:")
        End If
        'Startup Sound Enabled
        Write_Settings_CFG.WriteLine("StartupSoundEnabled:" & Settings.CheckBox_Startup_Sound_Enabled.Checked.ToString)
        'Startup Sound Path
        If File.Exists(Settings.TextBox_Startup_Sound_Path.Text) Then
            Write_Settings_CFG.WriteLine("StartupSoundPath:" & Settings.TextBox_Startup_Sound_Path.Text)
        Else
            Write_Settings_CFG.WriteLine("StartupSoundPath:")
        End If
        'Download Complete Sound Enabled
        Write_Settings_CFG.WriteLine("DownloadCompleteSoundEnabled:" & Settings.CheckBox_Download_Complete_Sound_Enabled.Checked.ToString)
        'Download Complete Sound Path
        If File.Exists(Settings.TextBox_Download_Complete_Sound_Path.Text) Then
            Write_Settings_CFG.WriteLine("DownloadCompleteSoundPath:" & Settings.TextBox_Download_Complete_Sound_Path.Text)
        Else
            Write_Settings_CFG.WriteLine("DownloadCompleteSoundPath:")
        End If
        Write_Settings_CFG.Close()
        Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("HH:mm:ss.fff tt") & "> " & "Information: Settings Saved" & vbCrLf) 'DEBUG ACTION LOG -
    End Sub
    'Load Settings
    Shared Sub Load_Settings()
        If File.Exists(Application.StartupPath & "\Data\Settings.cfg") Then
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Action: Loading Settings" & vbCrLf) 'DEBUG ACTION LOG -
            Try
                Dim Application_Root_Directory As String = Directory.GetDirectoryRoot(Application.StartupPath)
                Dim Settings_CFG() As String = File.ReadAllLines(Application.StartupPath & "\Data\Settings.cfg")
                'Download Completed Option
                If Settings_CFG(0).StartsWith("DownloadCompletedOption:") Then
                    Settings_CFG(0) = Settings_CFG(0).Substring(24)
                    If IsNumeric(Settings_CFG(0)) Then
                        If Settings_CFG(0) = "1" Then
                            Settings.RadioButton_Do_Nothing.Checked = True
                        ElseIf Settings_CFG(0) = "2" Then
                            Settings.RadioButton_Open_Download_File.Checked = True
                        ElseIf Settings_CFG(0) = "3" Then
                            Settings.RadioButton_Open_Download_Folder.Checked = True
                        ElseIf Settings_CFG(0) = "4" Then
                            Settings.RadioButton_Burn_ISO.Checked = True
                        Else
                            Settings_CFG = Nothing
                            Default_Settings()
                            Exit Sub
                        End If
                    End If
                Else
                    Settings_CFG = Nothing
                    Default_Settings()
                    Exit Sub
                End If
                'Download Enabled
                If Settings_CFG(1).StartsWith("DownloadEnabled:") Then
                    Settings_CFG(1) = Settings_CFG(1).Substring(16)
                    If (Settings_CFG(1)) = "True" Then
                        Settings.CheckBox_Download_Enabled.Checked = True
                    ElseIf (Settings_CFG(1)) = "False" Then
                        Settings.CheckBox_Download_Enabled.Checked = False
                    Else
                        Settings_CFG = Nothing
                        Default_Settings()
                        Exit Sub
                    End If
                Else
                    Settings_CFG = Nothing
                    Default_Settings()
                    Exit Sub
                End If
                'Download Path
                If Settings_CFG(2).StartsWith("DownloadPath:") Then
                    Settings_CFG(2) = Settings_CFG(2).Substring(13)
                    If Directory.Exists(Settings_CFG(2)) Then
                        Settings.RadioButton_Download_User.Checked = True
                        Settings.TextBox_Download_Path.Text = Settings_CFG(2)
                        Main.OS_Download_Path = Settings.TextBox_Download_Path.Text
                    Else
                        If Not Settings_CFG(2) = Nothing Then
                            If File.Exists(Application_Root_Directory & Settings_CFG(2).Substring(3)) Then
                                Settings.RadioButton_Download_User.Checked = True
                                Settings.TextBox_Download_Path.Text = Application_Root_Directory & Settings_CFG(2).Substring(3)
                                Main.OS_Download_Path = Settings.TextBox_Download_Path.Text
                            End If
                        Else
                            Settings.RadioButton_Download_Default.Checked = True
                        End If
                    End If
                Else
                    Settings_CFG = Nothing
                    Default_Settings()
                    Exit Sub
                End If
                'Startup Sound Enabled
                If Settings_CFG(3).StartsWith("StartupSoundEnabled:") Then
                    Settings_CFG(3) = Settings_CFG(3).Substring(20)
                    If (Settings_CFG(3)) = "True" Then
                        Settings.CheckBox_Startup_Sound_Enabled.Checked = True
                    ElseIf (Settings_CFG(3)) = "False" Then
                        Settings.CheckBox_Startup_Sound_Enabled.Checked = False
                    Else
                        Settings_CFG = Nothing
                        Default_Settings()
                        Exit Sub
                    End If
                Else
                    Settings_CFG = Nothing
                    Default_Settings()
                    Exit Sub
                End If
                'Startup Sound Path
                If Settings_CFG(4).StartsWith("StartupSoundPath:") Then
                    Settings_CFG(4) = Settings_CFG(4).Substring(17)
                    If File.Exists(Settings_CFG(4)) Then
                        Settings.TextBox_Startup_Sound_Path.Text = Settings_CFG(4)
                        Settings.RadioButton_Startup_Sound_User.Checked = True
                    Else
                        If Not Settings_CFG(4) = Nothing Then
                            If File.Exists(Application_Root_Directory & Settings_CFG(4).Substring(3)) Then
                                Settings.TextBox_Startup_Sound_Path.Text = Settings_CFG(4)
                                Settings.RadioButton_Startup_Sound_User.Checked = True
                            End If
                        End If
                    End If
                Else
                    Settings_CFG = Nothing
                    Default_Settings()
                    Exit Sub
                End If
                'Download Complete Sound Enabled
                If Settings_CFG(5).StartsWith("DownloadCompleteSoundEnabled:") Then
                    Settings_CFG(5) = Settings_CFG(5).Substring(29)
                    If (Settings_CFG(5)) = "True" Then
                        Settings.CheckBox_Download_Complete_Sound_Enabled.Checked = True
                    ElseIf (Settings_CFG(5)) = "False" Then
                        Settings.CheckBox_Download_Complete_Sound_Enabled.Checked = False
                    Else
                        Settings_CFG = Nothing
                        Default_Settings()
                        Exit Sub
                    End If
                Else
                    Settings_CFG = Nothing
                    Default_Settings()
                    Exit Sub
                End If
                'Download Complete Sound Path
                If Settings_CFG(6).StartsWith("DownloadCompleteSoundPath:") Then
                    Settings_CFG(6) = Settings_CFG(6).Substring(26)
                    If File.Exists(Settings_CFG(6)) Then
                        Settings.TextBox_Download_Complete_Sound_Path.Text = Settings_CFG(6)
                        Settings.RadioButton_Download_Complete_Sound_User.Checked = True
                    Else
                        If Not Settings_CFG(6) = Nothing Then
                            If File.Exists(Application_Root_Directory & Settings_CFG(6).Substring(3)) Then
                                Settings.TextBox_Download_Complete_Sound_Path.Text = Application_Root_Directory & Settings_CFG(6).Substring(3)
                                Settings.RadioButton_Download_Complete_Sound_User.Checked = True
                            End If
                        End If
                    End If
                Else
                    Settings_CFG = Nothing
                    Default_Settings()
                    Exit Sub
                End If
                Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Information: Settings Loaded" & vbCrLf) 'DEBUG ACTION LOG -
            Catch Ex As Exception
                Default_Settings()
            End Try
        Else
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Information: No Settings Found" & vbCrLf) 'DEBUG ACTION LOG - 
            Default_Settings()
        End If
    End Sub
    'Bad OS CFG
    Shared Sub Bad_OS_CFG()
        'Clear GUI And Data
        Clear_GUI_And_Data()
        'Remove OS from list
        Main.ListView1.Items.Remove(Main.ListView1.Items.Item(Main.Selected_Index))
        Main.ImageList_Main.Images.RemoveByKey(Main.Selected_Item)
        'Notify
        Main.NotifyIcon_Main.BalloonTipText = Main.Selected_OS & " contains invalid data and has been removed from the list."
        Main.NotifyIcon_Main.ShowBalloonTip(1500)
        Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Information: Bad OS CFG:" & Main.Selected_OS & vbCrLf) 'DEBUG ACTION LOG -
        Main.Selected_OS = Nothing
    End Sub
    'Check For Updates
    Shared Sub Check_For_Updates()
        Try
            If Main.OSs_Downloading.Count < 1 Then
                Dim Svn_Version As String
                Main.NotifyIcon_Requesting.Visible = True
                Main.NotifyIcon_Requesting.BalloonTipText = "Checking for updates."
                Main.NotifyIcon_Requesting.ShowBalloonTip(1500)
                Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Action: Checking for updates" & vbCrLf) 'DEBUG ACTION LOG - 
                'Store Stream
                Dim OSL_CFG_Stream As Stream = Main.CFG_WebClient.OpenRead("https://get-linux.googlecode.com/svn/trunk/Data/Version.cfg")
                'Read Stream
                Dim Version_Reader As New StreamReader(OSL_CFG_Stream)
                Svn_Version = Version_Reader.ReadLine()
                Version_Reader.Close()
                Main.NotifyIcon_Requesting.Visible = False
                Dim Users_Version As FileVersionInfo = FileVersionInfo.GetVersionInfo(Application.ExecutablePath.ToString)
                Dim User_Response As MsgBoxResult
                If Users_Version.FileVersion < Svn_Version Then 'User Need Update
                    Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Information: Update is available version " & Svn_Version & " Download update now?" & vbCrLf) 'DEBUG ACTION LOG - 
                    User_Response = MsgBox("Update is available version " & Svn_Version & vbCrLf & "Download update now?", MsgBoxStyle.YesNo, "Get Linux")
                    If User_Response = MsgBoxResult.Yes Then
                        Main.NotifyIcon_Main.Visible = False
                        Main.Hide()
                        Main.NotifyIcon_Requesting.Visible = True
                        Main.NotifyIcon_Requesting.BalloonTipText = "Updating..."
                        Main.NotifyIcon_Requesting.ShowBalloonTip(1500)
                        Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Action: Updating..." & vbCrLf) 'DEBUG ACTION LOG - 
                        'Rename the old version
                        My.Computer.FileSystem.RenameFile(Application.ExecutablePath.ToString, "Get Linux_OLD.exe")
                        'Download the new version
                        Main.CFG_WebClient.DownloadFile(New Uri("https://get-linux.googlecode.com/svn/trunk/Data/New Release/Get Linux.exe"), Application.StartupPath & "\Get Linux.exe")
                        'Start new version
                        Process.Start(Application.StartupPath & "\Get Linux.exe")
                        'Close old version
                        Application.Exit()
                    End If
                Else 'User Does Not Need A Update
                    Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Information: You have the latest version." & vbCrLf) 'DEBUG ACTION LOG - 
                    MsgBox("You have the latest version.", MsgBoxStyle.Information, "Get Linux")
                End If
                User_Response = Nothing
                Svn_Version = Nothing
                Users_Version = Nothing
            Else
                MsgBox("Please close any downloads before trying to update.", MsgBoxStyle.Information)
            End If
        Catch Wx As System.Net.WebException
            Main.NotifyIcon_Main.BalloonTipText = "Connection Failed: " & Wx.Message
            Main.NotifyIcon_Main.ShowBalloonTip(1500)
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Error: Connection Failed (" & Wx.Message & ")" & vbCrLf) 'DEBUG ACTION LOG -
            'Update Variables on debug window
            Debug.Variables()
        Catch Ex As Exception
            MsgBox(Ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    'Show / Hide Main Window
    Shared Sub Show_Hide_Main_Window()
        If Main.WindowState = FormWindowState.Normal Then
            Main.WindowState = FormWindowState.Minimized
            Main.Hide()
            Main.NotifyIcon_Main.BalloonTipText = "Minimized to tray."
            Main.NotifyIcon_Main.ShowBalloonTip(1500)
        Else
            Main.Show()
            Main.WindowState = FormWindowState.Normal
            Main.BringToFront()
            Main.Activate()
        End If
    End Sub
    'Clear GUI And Data
    Shared Sub Clear_GUI_And_Data()
        If Not Main.PictureBox_OS_Image.ImageLocation = (Nothing) Or _
          Not Main.Website = Nothing Or _
          Not Main.Download_32 = Nothing Or _
          Not Main.File_Size_32 = Nothing Or _
          Not Main.Download_64 = Nothing Or _
          Not Main.File_Size_64 = Nothing Or _
          Not Main.TextBox_About.Text = Nothing Or _
          Not Main.TextBox_Origin.Text = Nothing Or _
          Not Main.TextBox_Version.Text = Nothing Or _
          Not Main.TextBox_Desktop.Text = Nothing Or _
          Not Main.TextBox_File_Size.Text = Nothing Or _
          Not Main.ToolTip_Main.GetToolTip(Main.PictureBox_OS_Image) = Nothing Or _
          Not Main.ToolTip_Main.GetToolTip(Main.Button_Download) = Nothing Then
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Action: Clearing GUI And Data" & vbCrLf) 'DEBUG ACTION LOG -
            'Clear Images
            Main.PictureBox_OS_Image.ImageLocation = Nothing
            'Clear Strings
            Main.Website = Nothing
            Main.Download_32 = Nothing
            Main.File_Size_32 = Nothing
            Main.Download_64 = Nothing
            Main.File_Size_64 = Nothing
            'Clear GUI
            Main.TextBox_About.Clear()
            Main.TextBox_Origin.Clear()
            Main.TextBox_Version.Clear()
            Main.TextBox_Desktop.Clear()
            Main.TextBox_File_Size.Clear()
            'Reset tooltips
            Main.ToolTip_Main.SetToolTip(Main.PictureBox_OS_Image, Nothing)
            Main.ToolTip_Main.SetToolTip(Main.Button_Download, Nothing)
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Information: GUI And Data Cleared" & vbCrLf) 'DEBUG ACTION LOG -
        End If
    End Sub
    'Reconnect to server and selecting a Random OS
    Shared Sub Reconnect()
        Main.NotifyIcon_Main.Visible = False
        Main.NotifyIcon_Requesting.Visible = True
        Main.Hide()
        Main.NotifyIcon_Requesting.BalloonTipText = "Reconnecting..."
        Main.NotifyIcon_Requesting.ShowBalloonTip(1500)
        Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Action: Reconnecting" & vbCrLf) 'DEBUG ACTION LOG -
        'Checking Server Connection
        Main.NotifyIcon_Main.BalloonTipText = "Checking Server Connection..."
        Main.NotifyIcon_Main.ShowBalloonTip(1500)
        Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Information: Checking Server Connection" & vbCrLf) 'DEBUG ACTION LOG -
        Data.Check_Connection()
        'Verifying Server Connection
        Main.NotifyIcon_Main.BalloonTipText = "Verifying Server Connection..."
        Main.NotifyIcon_Main.ShowBalloonTip(1500)
        Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Information: Verifying Server Connection" & vbCrLf) 'DEBUG ACTION LOG -
        If Main.Connection = True Then
            'Build OSL
            OSL_List()
            'Auto Select Random Category And OS
            Auto_Select_OS()
            Main.NotifyIcon_Requesting.Visible = False
            Main.NotifyIcon_Main.Visible = True
            Main.Show()
            Main.NotifyIcon_Main.BalloonTipText = "Connected"
            Main.NotifyIcon_Main.ShowBalloonTip(1500)
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Information: Connected" & vbCrLf) 'DEBUG ACTION LOG -
        Else
            Main.NotifyIcon_Requesting.Visible = False
            Main.NotifyIcon_Main.Visible = True
            Main.Show()
            Main.NotifyIcon_Main.BalloonTipText = "Connection: Failed..."
            Main.NotifyIcon_Main.ShowBalloonTip(1500)
            Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Error: Connection Failed" & vbCrLf) 'DEBUG ACTION LOG -
        End If
    End Sub
    'Default Settings
    Shared Sub Default_Settings()
        Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Action: Loading Default Settings" & vbCrLf) 'DEBUG ACTION LOG - 
        'Download Completed Option
        Settings.RadioButton_Do_Nothing.Checked = True
        'Download Enabled
        Settings.CheckBox_Download_Enabled.Checked = True
        'Default Download
        Settings.RadioButton_Download_Default.Checked = True
        'Startup Sound Enabled
        Settings.CheckBox_Startup_Sound_Enabled.Checked = True
        'Default Startup Sound 
        Settings.RadioButton_Startup_Sound_Default.Checked = True
        'Completed Sound Enabled
        Settings.CheckBox_Download_Complete_Sound_Enabled.Checked = True
        'Completed Sound Path
        Settings.RadioButton_Download_Complete_Sound_Default.Checked = True
        Debug.TextBox_Action_Log.AppendText("<" & Now.ToString("hh:mm:ss.fff tt") & "> " & "Information: Default Settings Loaded" & vbCrLf) 'DEBUG ACTION LOG - 
    End Sub
    'Check Connection
    Shared Sub Check_Connection()
        Try
            Dim Check_Url As New System.Uri("https://get-linux.googlecode.com")
            Main.Request = System.Net.WebRequest.Create(Check_Url)
            Main.Request.Proxy = Nothing
            Main.Response = Main.Request.GetResponse
            Main.Response.Close()
            Main.Request = Nothing
            Main.Connection = True
        Catch ex As Exception
            Main.Request = Nothing
            Main.Connection = False
        End Try
    End Sub
    'ISO Burn
    Shared Sub isoburn()
        If File.Exists(Main.OS_Download_Path & Main.OS_Download) Then
            Shell("isoburn.exe " & Chr(34) & Main.OS_Download_Path & Main.OS_Download & Chr(34))
        End If
    End Sub
    'Clean Icons
    Shared Sub Clean_Icons()
        Dim Icons = Directory.GetFiles(Application.StartupPath & "\Data\Icons\")
        For Each imagefiles In Icons
            If Not AutoComplete_Operating_Systems.Contains(Path.GetFileNameWithoutExtension(imagefiles)) Then
                If Path.GetExtension(imagefiles) = ".png" Then
                    File.Delete(imagefiles)
                End If
            End If
        Next
    End Sub
End Class